export async function ImageToBase64(File) {
    
    const response = await uploadImgToBase64(File.file)

    
    return response.result.replace(/.*;base64,/, '')
}

function uploadImgToBase64(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader() //html5提供的一种异步文件读取机制
    reader.readAsDataURL(file) //将文件读取为Base64编码的数据URL
    reader.onload = function () {
      // 图片转base64完成后返回reader对象
      resolve(reader)
    }
    reader.onerror = reject
  })
}
